function pageAction(dom,pre,next,pageNum,succes) {
  // 定义页码
  var pages = pageNum
  // 获取当前页码
  var index = null
  // 
  var pageIndex = document.querySelector(dom)
  var oLeft = document.querySelector(pre)
  var oRight = document.querySelector(next)
  console.log(pageIndex)
  // 动态生成页码
  for (var i = 0; i < pages; i++) {
    pageIndex.innerHTML += `<span>${i + 1}</span>`
  }
  var oSpan = pageIndex.children
  oSpan[0].className = 'active'
  // 
  for (var i = 0; i < oSpan.length; i++) {
    oSpan[i].onclick = function () {
      for (var j = 0; j < oSpan.length; j++) {
        oSpan[j].className = ''
      }
      this.className = 'active'

      index = this.innerHTML
      succes(index)
      // console.log(index);
    }
  }
  // 点击上一页
  oLeft.onclick = function () {
    var spanActive = document.querySelector(`${dom} .active`)
    if (spanActive.previousElementSibling == null) {
      alert("到头了!")
    } else {
      spanActive.previousElementSibling.onclick()
    }
  }
  // 点击下一页
  oRight.onclick = function () {
    var spanActive = document.querySelector(`${dom} .active`)
    if (spanActive.nextElementSibling == null) {
      alert("到头了!")
    } else {
      spanActive.nextElementSibling.onclick()
    }
  }
}